<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<ul>
    <li>localStorage - 没有时间限制的数据存储</li>
    <li>sessionStorage - 针对一个 session 的数据存储</li>
</ul>
<script type="text/javascript">
    if(localStorage.pagecount){
        localStorage.pagecount=Number(localStorage.pagecount)+1;
    }else{
        localStorage.pagecount=1;
    }
    document.write("Visits " + localStorage.pagecount + " time(s) this localStorage.");
</script>
<p>刷新页面会看到计数器在增长。</p>

<p>请关闭浏览器窗口，然后再试一次，计数器已经重置了。</p>

<script type="text/javascript">

    if (sessionStorage.pagecount)
    {
        sessionStorage.pagecount=Number(sessionStorage.pagecount) +1;
    }
    else
    {
        sessionStorage.pagecount=1;
    }
    document.write("Visits " + sessionStorage.pagecount + " time(s) this session.");

</script>

<p>刷新页面会看到计数器在增长。</p>

<p>请关闭浏览器窗口，然后再试一次，计数器已经重置了。</p>
</body>
</html>